﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentValidation;
using Mulala.Cavan.Domain.MainBoundedContext.Resources;

namespace Mulala.Cavan.Domain.MainBoundedContext.SecurityModule
{
    public class UserAccountValidator : AbstractValidator<UserAccount>
    {
        public UserAccountValidator()
        {
            RuleFor(ua => ua.Name).NotEmpty().WithMessage(Messages.Validate_UserAccountNameIsInvalid).Length(2, 20).WithMessage(Messages.Validate_UserAccountNameIsInvalid);
            RuleFor(ua => ua.Password).NotEmpty().WithMessage(Messages.Validate_UserAccountPasswordIsInvalid).Matches(@"^[a-z1-9]{6,20}$").WithMessage(Messages.Validate_UserAccountPasswordIsInvalid);
            RuleFor(ua => ua.Email).EmailAddress().WithMessage(Messages.Validate_EmailIsInvalid);
            RuleFor(ua => ua.LoginName).NotEmpty().WithMessage(Messages.Validate_UserAccountNameIsInvalid).Length(2, 20).WithMessage(Messages.Validate_UserAccountNameIsInvalid);
        }
    }
}
